import { serviceApiPrefix } from "@/common/serviceConfig";
import { appFetch } from "@/utils/tools";


export const uploadFileApi = async (files: FileList) => {
  const formData = new FormData();
  formData.append('file', files[0]);
  const res = await fetch(
    `${serviceApiPrefix}/upload`,
    {
      method: 'post',
      body: formData,
    }
  )
  const data = await res.json()
  if (data.success) {
    return data
  } else {
    throw data
  }
}